package com.bupt.secret.dto;

import com.sun.jna.Structure;
import lombok.Data;

import java.util.Arrays;
import java.util.List;

import static com.bupt.secret.constant.BuptConstant.RSAREF_MAX_LEN;
import static com.bupt.secret.constant.BuptConstant.RSAREF_MAX_PLEN;

/**
 * @author ShiShuMin
 * @version v1.0
 * @ClassName BuptConstant
 * @Date: 2024/8/27 11:34
 * @Description: 私钥结构
 */
@Data
public class RSArefPrivateKey extends Structure {

    /**
     * 模长
     */
    public int bits;
    /**
     * 模N,数据长度256
     */
    public byte[] m = new byte[RSAREF_MAX_LEN];
    /**
     * 公钥指数
     */
    public byte[] e = new byte[RSAREF_MAX_LEN];
    /**
     * 私钥指数
     */
    public byte[] d = new byte[RSAREF_MAX_LEN];
    /**
     * 素数p和q
     */
    public byte[] prime = new byte[2 * RSAREF_MAX_PLEN];
    /**
     * Dp和Dq
     */
    public byte[] pexp = new byte[2 * RSAREF_MAX_PLEN];
    /**
     * 系数i
     */
    public byte[] coef = new byte[RSAREF_MAX_PLEN];

    @Override
    protected List<String> getFieldOrder() {
        return Arrays.asList("bits", "m", "e", "d", "prime", "pexp", "coef");
    }
}